package com.penghaisoft.microwms.product.service.impl;

import com.penghaisoft.microwms.common.data.model.ProScrapOutSn;
import com.penghaisoft.microwms.common.dto.Resp;
import com.penghaisoft.microwms.common.page.Pager;
import com.penghaisoft.microwms.common.service.BaseService;
import com.penghaisoft.microwms.product.dao.ProScrapOutSnMapper;
import com.penghaisoft.microwms.product.service.IProScrapOutSnService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 业务逻辑实现类
 * </p>
 * 
 * @author
 * @createDate 
 **/
@Service("proScrapOutSnService")
public class ProScrapOutSnServiceImpl extends BaseService implements IProScrapOutSnService{
		@Resource
		private ProScrapOutSnMapper proScrapOutSnMapper;
		
	  /**
	   * 新增记录
	   * @param proScrapOutSn
	   * @return
	   */
		@Override
		public Resp create(ProScrapOutSn proScrapOutSn){
			proScrapOutSnMapper.create(proScrapOutSn);
			return success();
		}

	  /**
	   * 删除记录（逻辑删除）
	   * @param proScrapOutSn
	   * @return
	   */
		@Override
		public Resp delete(ProScrapOutSn proScrapOutSn){
			proScrapOutSnMapper.delete(proScrapOutSn);
			return success();
		}
		
	  /**
	   * 查询列表
	   * @param page
	   * @param condition
	   * @return
	   */
		@Override
		public Pager<ProScrapOutSn> findListByCondition(int page, int rows, ProScrapOutSn condition){
		    Pager<ProScrapOutSn> pager = new Pager<>();
		    pager.setPage(page);
		    pager.setRows(rows);
    		condition.preQuery();
    		long size = proScrapOutSnMapper.queryCount(condition);
    		List<ProScrapOutSn> records = new ArrayList<>();
    		if(size > 0){
    			records = proScrapOutSnMapper.queryList(pager,condition);
    		}
			pager.setRecords(records);
			pager.setTotalCount(size);
			return pager;
		}

	  /**
	   * 查询单条
	   * @param id
	   * @return
	   */
		@Override
		public ProScrapOutSn findById(String id){
			return proScrapOutSnMapper.queryById(id);
		}
		
	  /**
	   * 修改记录
	   * @param proScrapOutSn
	   * @return
	   */
		@Override
		public Resp update(ProScrapOutSn proScrapOutSn){
			proScrapOutSnMapper.updateBySelect(proScrapOutSn);
			return success();
		}

}
